<script setup>
import {getCurrentInstance, onMounted} from "vue";
import eventBus  from '../../event/eventBus.js';
const NAME = '2D';

const { appContext } = getCurrentInstance();
let global = appContext.config.globalProperties;
let is2D = false;


onMounted(() => {
    eventBus.on('mapToolBarClick', (data) => {
      if(data == NAME){
          if(is2D){
            //进入3d模式
            global.$viewer.scene.screenSpaceCameraController.enableTilt = true;
            global.$viewer.camera.flyTo({
              duration:0.5,
              destination: Cesium.Cartesian3.fromDegrees(
                  window.mapPosition.lon,
                  window.mapPosition.lat,
                  20000000
              ), //设置位置
              orientation: {
                heading: Cesium.Math.toRadians(window.mapPosition.heading),
                pitch: Cesium.Math.toRadians(window.mapPosition.pitch),
                roll: 0,
              },
            });
          }else{
            //进入2d模式
            global.$viewer.scene.screenSpaceCameraController.enableTilt = false;
            global.$viewer.camera.flyTo({
              duration:0.5,
              destination: Cesium.Cartesian3.fromDegrees(
                  window.mapPosition.lon,
                  window.mapPosition.lat,
                  233333

              ), //设置位置
              orientation: {
                heading: Cesium.Math.toRadians(window.mapPosition.heading),
                pitch: Cesium.Math.toRadians(window.mapPosition.pitch),
                roll: 0,
              },
            });

          }

        is2D = !is2D;
      }else{
        //进入3d模式
        global.$viewer.scene.screenSpaceCameraController.enableTilt = true;
      }
    });

});
</script>

<template >
</template>